Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
Nodemailer throws "No recipients defined" error but email is actually sent

I am experiencing an unexpected behaviour from nodemailer:

here is my code:

  let transporter = nodemailer.createTransport({
   host: 'outlook.office365.com',



auth: {
  user: process.env.MAIL_USER, // generated ethereal user
  pass: process.env.MAIL_PASS, // generated ethereal password
},
   tls: {
    rejectUnauthorized: false
}});



 let info =  transporter.sendMail({

 from: '"Mark ๐Ÿ‘ป"mymail@outlook.com', 
 to: "anothermailOfMine@gmail.com", 
 subject: "Hello โœ”", 
 text: "Hello world?", 
 html: `<b>
 <a href='http://localhost:3000/activate_user/${result._id}'>
 <button>Activate 
 profile</button></a> 
 </b>`, // html body
 });

transporter.sendMail(info, function (err, info) {
if (err) {
console.log(err);
res.json(err);
} else {
  console.log(' mail sent');
res.json({success:true, message:''});
}})};

The sendMail method returns an error even if the mail is actually sent successfully, which means that the front-end never receives a positive response about the sending, that's the error i just mentioned:

Error: No recipients defined
at SMTPConnection._formatError 

I wonder if I am doing something wrong.

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

I did find out what the problem was eventually: the send mail method needed to be called in an asynchronous function.

about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!